// we7/pages/fenLei/fenLeiList.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1,
    limit:10,
    optionsId:'',
    data:[],
    goodsList:'',
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
  },
  showModal(e) {
    this.setData({
      modalName: e.currentTarget.dataset.target
    })
  },
  hideModal(e) {
    this.setData({
      modalName: null
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      ccc:"#000"
    });
    var that=this;
    app.util.request({
      url: 'admin/WxGoodsApi/goodsList',
      data:{
        id: options.id,
        page: this.data.page,
        limit: this.data.limit,
        order_type: 3,
      },
      method: 'post',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res){
        var data = res.data.data
        for (var i = 0; i < data.length; i++){
          data[i]['goods_list_image'] = app.globalData.url + data[i]['goods_list_image'];
        }
        that.setData({
          goodsList: res.data.data,
          optionsId:options.id
        })
      }
    });
  },
  // 最新
  zuiNew: function(data){
    this.check(data)
    var that = this;
    app.util.request({
      url: 'admin/WxGoodsApi/goodsList',
      data: {
        id: this.data.optionsId,
        page: this.data.page,
        limit: this.data.limit,
        order_type: data.target.dataset.style,
      },
      method: 'post',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res){
        console.log(res)
        var data = res.data.data
        for (var i = 0; i < data.length; i++){
          data[i]['goods_list_image'] = app.globalData.url + data[i]['goods_list_image'];
        }
        that.hideModal();
        that.setData({
          goodsList: res.data.data,
          data: data
        })
      }
    });
  },
  check:function(data){
    var id = data.currentTarget.dataset.id;
    var ccc = "#666666";
    var bbb = "#666666";
    var aaa = "#666666";
    var pri_sheng = "#666";
    var pri_jiang="#666";
    if(id==1){ccc="#000";}
    if(id == 2){bbb = "#000";}
    if(id == 3){aaa = "#000";}
    if (id == 4) { pri_sheng = "orange"; }
    if (id == 5) { pri_jiang="orange";}
    this.setData({
      bbb:bbb,
      ccc:ccc,
      aaa:aaa,
      pri_sheng: pri_sheng,
      pri_jiang: pri_jiang
    })
  },

 
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})